package week12;
import java.util.*;
import java.lang.*;
public class MySort {
    public static void main(String[] args) {
        String[] toSort = {"aaa:10:1:1",
                "ccc:30:3:4",
                "bbb:50:4:5",
                "ddd:20:5:3",
                "eee:40:2:20"};

        int [] tmp = new int [toSort.length];
        int val;
        String [] s;

        System.out.println("Before sort:");
        for (String i : toSort) {
            System.out.println(i);

        }

        for(int i = 0; i < toSort.length; i++) {
            s = toSort[i].split(":");
            tmp[i] = Integer.parseInt(s[3]);
        }
        Arrays.sort(tmp);

        System.out.println("After sort:");
        for(int i = 0; i < toSort.length; i++)
            for(int j = 0; j < toSort.length; j++){
                s = toSort[j].split(":");
                val = Integer.parseInt(s[3]);
                if(val == tmp[i]) {
                    System.out.println(toSort[j]);
                }
            }
    }
}